/**
 * create by undeRdoG on  2021-06-02  11:04
 * 凡心所向，素履以往，生如逆旅，一苇以航。
 */
public class TestDynamicBind {

    public static void main(String[] args) {
        Person person = new Worker();

        /**
         *
         * person
         * hello worker
         *  多态测试：
         *  可以看出，属性是静态绑定的，在编译期间就绑定死的
         *  方法调用是动态绑定
         * */
        System.out.println((person).name);
        person.hello();
    }
}


class Person {
    String name = "person";

    public void hello() {
        System.out.println("hello person");
    }
}

class Worker extends Person {
    String name = "worker";

    public void hello() {
        System.out.println("hello worker");
    }
}